package mercury.dao;
import java.util.Map;
/**
 * The application's common Catalog Data Access Object (DAO).
 * All Catalog Database DAO should implement this interface.
 * @author tristan
 */
public interface CatalogDAOInterface {

    /**
     * Prepares the CatalogDAO using the provided parameters.
     * The parameters are controled and known by the
     * implementing classes.
     * @param params An array of parameters that this class knows how to use.  
     * Similar to the public static void main(String args[])
     * @throws dao.CatalogException Problem initializing DAO 
     * hence cannot create catalog DAO
     */
    public void init(Map params) throws CatalogException;
    
    /**
     * Inserts a new item in the database
     * based on the data in the map.
     * @param map A Map where the key is the element name
     * and the value is an array of values.
     * Only the first value in the array
     * will be used.
     * @return ID Returns a string containing the ID
     * of the newly inserted item.
     */
    public String insert(Map map) throws CatalogException;
    
    /**
     * Updates a item with ID id with the
     * information in the map.
     * @param id The ID of the item
     * @param map A Map where the key is the element name
     * and the value is an array of values.
     * Only the first value in the array
     * will be used.
     * @throws dao.CatalogException Exception when no item
     * exists with ID id.
     */
    public void update(Map map) throws CatalogException;
    
    /**
     * Delete the item with the ID id.
     * @param id The ID of the item
     * @throws dao.CatalogException Exception when no item
     * exists with ID id.
     */
    public void delete(Map map) throws CatalogException;
    
    /**
     * Obtain the books, in XML, that match the criteria
     * defined in Map.
     * @param criteria A Map with the criteria for the search.
     * The map contains keys with value arrays.
     * The criteria is all the values in the
     * value array for the element key.
     * @return An XML snippet of the item
     */
    public String[][] select(Map criteria) throws CatalogException;
    public String selectValue(Map criteria) throws CatalogException;
    public Map selectField(Map criteria) throws CatalogException;
    public String getMax(String column, String table) throws CatalogException;
    public String getCatalogMetadata() throws CatalogException;
    public void closeConnection() throws CatalogException ;
}
